<html>

	<?php if ($errors): ?>
		<p class="message">Some errors were encountered, please check the details you entered.</p>
		<ul class="errors">
		<?php foreach ($errors as $message): ?>
			<li><?php echo $message ?></li>
		<?php endforeach ?>
		</ul>
	
		<?php endif ?>
	
		<?php		
		if(!(isset($_SESSION['candidato']))){
			echo "Não pode acessar sem preencher formularios anteriores";
		}
		else{
			
		?>

	<script>
		function mascara(o,f){
	   		v_obj=o
	   		v_fun=f
	   		setTimeout("execmascara()",1)
		}
	
		function execmascara(){
			v_obj.value=v_fun(v_obj.value)
		}
	
		function cep(v){
			v=v.replace(/\D/g,"")                    //Remove tudo o que não é dígito
			v=v.replace(/(\d{5})(\d)/,"$1-$2")       //Coloca um hífen entre o quinto e o sexto dígitos
			return v;
		}

		function numeroDaCasa(v){
			v=v.replace(/\D/g,"")                    //Remove tudo o que não é dígito
			return v;
		}
	
	</script>

	<body>
		<form method="post"	action="<?php echo url::site() ?>GerenciadorDeEndereco/validarForm" />
		<input type="hidden" name="IdEndereco" value="<?php 
		if($formularioDeEndereco->isCampoPreenchido("IdEndereco")){
			echo $formularioDeEndereco->obterCampoPreenchido("IdEndereco"); 
		}
		else{
			echo 0; 
		}
		
		?>"/>
		<div class="estilo_formulario">
		
			<label>País
	        		<span class="small">País onde mora</span>
	    	</label>
	    	<input class="input_text" type="text" name="Pais" size="15"
				value="<?php 
					if($formularioDeEndereco->isCampoPreenchido("Pais")){
						echo $formularioDeEndereco->obterCampoPreenchido("Pais");
					}
				?>"/>
				<?php if(isset($errors['Pais'])){?>
					<div class="aviso"> <?php echo Html::image('assets/images/error.png', array('class'=>'img_erro'));?> &nbsp;&nbsp;<p class="erro"> <?php echo $errors['Pais']?> </p> </div>
				<?php } ?>
			
			<label>Estado
	        		<span class="small">Estado onde mora</span>
	    	</label>
	    	
	
			<span class="campo_dropbox">
				<select name="Estado">
					<option value=""></option>
					<?php $listaDeEstados = array(
										  1 => "Acre", 
										  2 => "Alagoas",
										  3 => "Amapá", 
										  4 => "Amazonas",
										  5 => "Bahia",
										  6 => "Ceará",
										  7 => "Distrito Federal",
										  8 => "Espirito Santo",
										  9 => "Goiás",
										  10 => "Maranhão",
										  11 => "Mato Grosso do Sul",
										  12 => "Mato Grosso",
										  13 => "Minas Gerais",
										  14 => "Pará",
										  15 => "Paraíba",
										  16 => "Paraná",
										  17 => "Pernambuco",
										  18 => "Piauí",
										  19 => "Rio de Janeiro",
										  20 => "Rio Grande do Norte",
										  21 => "Rio Grande do Sul",
										  22 => "Rondônia",
										  23 => "Roraima",
										  24 => "Santa Catarina",
										  25 => "São Paulo",
										  26 => "Sergipe",
										  27 => "Tocantins",
										  );
										  
					if($formularioDeEndereco->isCampoPreenchido("Estado")){
						foreach ($listaDeEstados as $estado){
							if(strcmp($estado, $formularioDeEndereco->obterCampoPreenchido("Estado")) == 0){
								echo "<option selected=\"selected\" value=\"" . $estado ."\">" . $estado . "</option>";
							}
							else{
								echo "<option value=\"" . $estado ."\">" . $estado . "</option>";
							}
						}
					}
					else{
						foreach ($listaDeEstados as $estado){
							echo "<option value=\"" . $estado ."\">" . $estado . "</option>";
						}
					}						  
					?>					
				</select>
				</span>
				<?php if(isset($errors['Estado'])){?>
				<div class="aviso"> <?php echo Html::image('assets/images/error.png', array('class'=>'img_erro'));?> &nbsp;&nbsp;<p class="erro"> <?php echo $errors['Estado']?> </p> </div>
				<?php } ?>
			<!--
			<font color="blue">(*)ESTADO: </font> <select name="Estado">
				<option value=""></option>
				<option value="AC">Acre</option>
				<option value="AL">Alagoas</option>
				<option value="AP">Amapá</option>
				<option value="AM">Amazonas</option>
				<option value="BA">Bahia</option>
				<option value="CE">Ceará</option>
				<option value="DF">Distrito Federal</option>
				<option value="ES">Espirito Santo</option>
				<option value="GO">Goiás</option>
				<option value="MA">Maranhão</option>
				<option value="MS">Mato Grosso do Sul</option>
				<option value="MT">Mato Grosso</option>
				<option value="MG">Minas Gerais</option>
				<option value="PA">Pará</option>
				<option value="PB">Paraíba</option>
				<option value="PR">Paraná</option>
				<option value="PE">Pernambuco</option>
				<option value="PI">Piauí</option>
				<option value="RJ">Rio de Janeiro</option>
				<option value="RN">Rio Grande do Norte</option>
				<option value="RS">Rio Grande do Sul</option>
				<option value="RO">Rondônia</option>
				<option value="RR">Roraima</option>
				<option value="SC">Santa Catarina</option>
				<option value="SP">São Paulo</option>
				<option value="SE">Sergipe</option>
				<option value="TO">Tocantins</option>
			</select> <br />
			<br />
			-->
				<label>Cidade
	        		<span class="small">Cidade onde mora</span>
	    		</label>
				<input class="input_text" type="text" name="Cidade" size="30"
				value="<?php 
					if($formularioDeEndereco->isCampoPreenchido("Cidade")){
						echo $formularioDeEndereco->obterCampoPreenchido("Cidade");
					}
							
				?>" /> 
				<?php if(isset($errors['Cidade'])){?>
					<div class="aviso"> <?php echo Html::image('assets/images/error.png', array('class'=>'img_erro'));?> &nbsp;&nbsp;<p class="erro"> <?php echo $errors['Cidade']?> </p> </div>
				<?php } ?>
			
				<label>Rua/Av.
	        	<span class="small">Rua/Avenida onde mora</span>
	    		</label>
				<input class="input_text" type="text" name="Endereco" size="50"
				value="<?php 
					if($formularioDeEndereco->isCampoPreenchido("Endereco")){
						echo $formularioDeEndereco->obterCampoPreenchido("Endereco");
					}
							
				?>" />
				<?php if(isset($errors['Endereco'])){?>
					<div class="aviso"> <?php echo Html::image('assets/images/error.png', array('class'=>'img_erro'));?> &nbsp;&nbsp;<p class="erro"> <?php echo $errors['Endereco']?> </p> </div>
				<?php } ?> 
				
				<label>Número
	        	<span class="small">Número onde mora</span>
	    		</label>
				<input class="input_text" type="text" name="NumeroDaCasa" maxlength="5" onkeypress="mascara(this, numeroDaCasa)" size="3"	value="<?php 
					if($formularioDeEndereco->isCampoPreenchido("NumeroDaCasa")){
						echo $formularioDeEndereco->obterCampoPreenchido("NumeroDaCasa");
					}
							
				?>" /> 
				<?php if(isset($errors['NumeroDaCasa'])){?>
					<div class="aviso"> <?php echo Html::image('assets/images/error.png', array('class'=>'img_erro'));?> &nbsp;&nbsp;<p class="erro"> <?php echo $errors['NumeroDaCasa']?> </p> </div>
				<?php } ?> 
				
				<label>Complemento
	        	<span class="small">Apartamento, Bloco...</span>
	    		</label>
				<input class="input_text" type="text" name="Complemento" size="10"	value="<?php 
				if($formularioDeEndereco->isCampoPreenchido("Complemento")){
					echo $formularioDeEndereco->obterCampoPreenchido("Complemento");
				}
							
				?>" />
				<?php if(isset($errors['Complemento'])){?>
				<div class="aviso"> <?php echo Html::image('assets/images/error.png', array('class'=>'img_erro'));?> &nbsp;&nbsp;<p class="erro"> <?php echo $errors['Complemento']?> </p> </div>
				<?php } ?>  
			
				<label>Bairro
	        	<span class="small">Bairro onde mora</span>
	    		</label>
				<input class="input_text" type="text" name="Bairro"  value="<?php 
				if($formularioDeEndereco->isCampoPreenchido("Bairro")){
					echo $formularioDeEndereco->obterCampoPreenchido("Bairro");
				}
							
				?>" />
				<?php if(isset($errors['Bairro'])){?>
				<div class="aviso"> <?php echo Html::image('assets/images/error.png', array('class'=>'img_erro'));?> &nbsp;&nbsp;<p class="erro"> <?php echo $errors['Bairro']?> </p> </div>
				<?php } ?> 
			
				<label>CEP
	        	<span class="small">CEP onde mora</span>
	    		</label>
				<input class="input_text" type="text" name="Cep"  maxlength="9" onkeypress="mascara(this,cep)" value="<?php 
				if($formularioDeEndereco->isCampoPreenchido("Cep")){
					echo $formularioDeEndereco->obterCampoPreenchido("Cep");
				}
				?>" />
				<?php if(isset($errors['Cep'])){?>
				<div class="aviso"> <?php echo Html::image('assets/images/error.png', array('class'=>'img_erro'));?> &nbsp;&nbsp;<p class="erro"> <?php echo $errors['Cep']?> </p> </div>
				<?php } ?>  
			
				<input class="botao_recuar" type="submit" name="form_button" value ="Voltar">
				<input class="botao_avancar" type="submit" name="form_button" value ="Proximo">
			</div>
		</form>
	</body>
</html>

<?php }	?>
